package com.xiaoma.springbootannotation.test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Lookup;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @description:
 * @Author: xiaoma
 * @Date: 2021/9/15 14:08
 */
@Component
public class A {
    @Autowired
    private ApplicationContext applicationContext;
    public void print(){
        System.out.println("A:"+this);
        getB().print();
    }
    @Lookup
    public B getB(){
        ExecutorService threadPool1 = Executors.newCachedThreadPool();  //可伸缩的线程池
        ExecutorService threadPool2 = Executors.newFixedThreadPool(5); //固定大小的线程池
        ExecutorService threadPool3= Executors.newSingleThreadExecutor(); //单个线程
        return applicationContext.getBean("b",B.class);
    }
}
